$(function() {
   
    $('.layui-plus').click(function() {
        layer_iframe('添加职业', 'edit');
    });

    var editObj=null,ptable=null,treeGrid=null,tableId='data_table',layer=null,laytable = null;
        layui.config({
            base:'/static/plugin/tree/design/extend/'
        }).extend({
            treeGrid:'treeGrid'
        }).use(['treeGrid','layer','table'],function(){
            treeGrid = layui.treeGrid;
            layer  = layui.layer;
            //laytable = layui.table;
            window.options = {
                id:'data_table',
                elem:'.layui-table.data-table',
                url:location.pathname + location.search,
                where: {},
                //cellMinWidth: 100
                idField:'id'//必須字段
                ,treeId:'id'//树形id字段名称
                ,treeUpId:'p_id'//树形父id字段名称
                ,treeShowName:'name'//以树形式显示的字段
                ,heightRemove:[".dHead",80]//不计算的高度,表格设定的是固定高度，此项不生效
               // ,isFilter:false
                ,height:'10'
                ,iconOpen:false//是否显示图标【默认显示】
                ,isOpenDefault:true//节点默认是展开还是折叠【默认展开】
                ,loading:true
                ,method:'get'
                ,isPage:false
                ,done:function(res, curr, count){
                  
                     if (!res.data && curr > 1) {
                        window.options.page = {
                            curr: curr - 1
                        }
                        window.tableIns.reload(window.options);
                    }
                }
                ,cols: [[
    
                    {
                        field:'name',title:'职业名称',align:'center',style:'text-align:left',

                    },
                   
                    {title: '操作', align:'center', toolbar: '#toolbar_normal'}
                ]]

            }
            window.tableIns = treeGrid.render(window.options);

    
            treeGrid.on('tool(data_table)',function(obj){
                if(obj.event == 'edit'){
                    layer_iframe('编辑职业', 'edit?id=' + obj.data.zhiye);
                }else if(obj.event == 'del'){
                    _ajax_remove('确定删除该职业吗','home_shop',obj.data.shop_id);
                    
                }
            });
            
        });
       
});
